#include "UdpServer.hpp"
#include <iostream>
#include "IntAddr.hpp"
#include <memory>
#include "Dir.hpp"

std::string defaulthandler(const std::string &msg)
{

    return "hello " + msg;
}

int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        std::cerr << "Usage: " << argv[0] << " port" << std::endl;
        return 1;
    }

    // std::string ip = argv[1];
    uint16_t port = std::stoi(argv[1]);

    Enable_Console_Log_Strategy();

    dir _dir;
    _dir.LoadDir();

    std::unique_ptr<UdpServer> Ser = std::make_unique<UdpServer>(port, [&_dir](InetAddr &client, const std::string &word) -> std::string
                                                                 { return _dir.Translate(word, client); });

    Ser->Init();
    Ser->Start();

    return 0;
}